In this demo, you will learn about
in line styles in React Components. You have learned the regular way of
styling React Components using the class name attribute. Now you will see another way of styling
React Components that are using in line styles. In line styles can be applied
directly in the element or tag and have the highest precedence
over any other styling. To get started you have the boilerplate
with one component that contains two headings wrapped around div and
section elements. Run the application without
applying any styles first. The application runs fine, but
there is no styling applied. To include in line styles
at a style attribute. While applying the in line styles, you need to note that there
will be two curly brackets. Because for pure JavaScript
expressions to be used in JSX, the JavaScript expressions have
to be included in curly brackets. The outer curly bracket injects JavaScript
into JSX the inner curly brackets create an object literal and the styles are
passed as object literals to the element. The properties are separated by a comma. Also, the attributes are written in
camel case and not separated by a dash. Similarly add some style
to the div element too. Now run the application. The application runs fine
with the styles applied. Thank you.